package com.woniu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.vo.RlRoadMaintainerVo;
import com.woniu.vo.StreetVo;
import com.woniu.pojo.Maintainer;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MaintainerMapper extends BaseMapper<Maintainer> {


    @Select("select r.name from t_maintainer m,rl_road_maintainer l,t_road r where m.id = l.maintainer_id and l.road_id" +
            "= r.id and m.id = #{id}")
    List<String> selectStreetNameById(Long id);
    @Select("select * from t_road ")
    List<StreetVo> selectStreetList();
    @Insert("insert into rl_road_maintainer (road_id,maintainer_id,create_time,update_time) values (#{roadId},#{maintainerId},#{createTime},#{updateTime})")
    void addRlRoadMaintainer(RlRoadMaintainerVo rlRoadMaintainerVo);
    @Select("select r.* from t_maintainer m,rl_road_maintainer l,t_road r where m.id = l.maintainer_id and l.road_id" +
            "= r.id and m.id = #{id}")
    @ResultType(StreetVo.class)
    List<StreetVo> selectStreetByMaintainerId(Long id);
    @Delete("delete from rl_road_maintainer where maintainer_id = #{id}")
    void deleteRelationByMaintainerId(Long id);
    @Update("update t_maintainer set status = '0' where id = #{id}" )
    int updateStatusToStopById(Long id);
    @Update("update t_maintainer set status = '1' where id = #{id}" )
    int updateStatusToUseById(Long id);
}
